package com.foxzzz.binary.search;

import java.util.Arrays;

public class Solution287 {
    public int findDuplicate(int[] nums) {
        Arrays.sort(nums);
        for (int i = 0; i < nums.length; i++) {
            if(nums[i+1]==nums[i])
                return nums[i];
        }
        return -1;
    }



    public static void main(String[] args) {
        System.out.println(new Solution287().findDuplicate(new int[]{1,3,4,2,2,2}));
    }
}
